let topBox = document.querySelector(".close");
let sideBox = document.querySelector(".side");
let top01 = document.querySelector("#top01");
let top02 = document.querySelector("#top02");
// console.log(top02);




top02.onclick = function() {
    // sideBox.style.background = "yellow"
    sideBox.style.right = "0px"
    top02.style.display = "none"
    top01.style.display = "block"
}
top01.onclick = function() {
    // sideBox.style.background = "yellow"
    sideBox.style.right = "-290px"
    top02.style.display = "block"
    top01.style.display = "none"
}









// console.log($);
$('.nav').children('li').click(function() {
    // console.log(111);
    //获取当前的点击索引  电梯按钮
    // console.log($(this).index());
    //根据按钮找到楼层
    // console.log($('.floor').eq($(this).index()));

    //找到楼层就可以找到楼层距顶部的位置
    // console.log($('.floor').eq($(this).index()).offset().top);

    // $('html').scrollTop($('.floor').eq($(this).index()).offset().top)

    $('html').animate({
        scrollTop: $('.floor').eq($(this).index()).offset().top
    }, 2000)
})












let cartbtn = document.getElementById("cartbtn")
let personbtn = document.getElementById("personBtn")
console.log(personbtn);
// console.log(poid);
// console.log(ed.isLogin);
// console.log((userMsg.msg).isLogin === "ok");




cartbtn.onclick = function() {
    if (localStorage.getItem("userMsg")) {
        location.href = "../www/cart.html";
    } else {
        if (confirm("请先登录,才能访问购物车,是否跳转到登录页面")) {
            location.href = "http://localhost:3000/www/login.html"
        }
    }
}


personbtn.onclick = function() {
    if (JSON.parse(localStorage.getItem("userMsg"))) {
        location.href = "http://localhost:3000/www/PersonalCenter.html";
    } else {
        if (confirm("请先登录后访问个人中心")) {
            location.href = "http://localhost:3000/www/login.html";
        }
    }
};
// console.log(JSON.parse(localStorage.getItem("userMsg")));